# CC 编译工具声明
# stc 烧录工具位置
# 功能是编译并完成下载
CC = sdcc
stc = python3 ./stcflash.py
include = ./include/

all : main.bin 

main.bin : main.hex
	objcopy -I ihex -O binary build/main.hex build/main.bin
    
main.hex : main.ihx
	packihx build/main.ihx > build/main.hex

main.ihx : main.rel oled.rel infrared.rel timer0.rel
	$(CC) build/main.rel build/oled.rel build/infrared.rel build/timer0.rel -o build/

main.rel : src/main.c
	$(CC) -c src/main.c -Iinclude -o build/
    
oled.rel : src/oled.c
	$(CC) -c src/oled.c -Iinclude -o build/

infrared.rel: src/infrared.c
	$(CC) -c src/infrared.c -Iinclude -o build/

timer0.rel: src/timer0.c
	$(CC) -c src/timer0.c -Iinclude -o build/

clean:
	rm -rf build/*

download: main.bin
	$(stc) build/main.bin -p /dev/ttyCH341USB0 -l 9600



